<?php
/**
 * Created by PhpStorm.
 * User: sakura
 * Date: 2019/4/25
 * Time: 5:56 PM
 */

namespace app\common\model;


//use app\common\model\Model;
use traits\model\SoftDelete;

class Driver extends Model
{
    use SoftDelete;

    protected $name = 'driver';
    protected $autoWriteTimestamp = true;

    public function car(){
        return $this->hasOne('Car','dr_id','id');
    }

    public function orders(){
        return $this->hasOne('Orders','dr_id','id');
    }
    protected function getAdminStatusTextAttr($vaule, $data)
    {
        $text = [
            0 => '禁用',
            1 => '正常',
            2 => '已接单'
        ];
        return $text[$data['status']];
    }
    protected function getOrderStateAttr($value,$data){
        $text = [
            0 => '未认证',
            1 => '已认证',
        ];
        return $text[$data['state']];
    }
    protected function getUpdateTimeAttr($value)
    {
        return $value>0?date('Y-m-d H:i:s',$value):'/';
    }


    protected function getCreateTimeAttr($value)
    {
        return $value>0?date('Y-m-d H:i:s',$value):'/';
    }
}